home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / General / GCC 1.37.1r15 / Manual / TeX / texinfo.tex < prev   
Text File  |  1990-02-21  |  75KB  |  2,358 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %   Copyright (C) 1985, 1986, 1988 Free Software Foundation, Inc.
  4.  
  5. %GNU CC is free software; you can redistribute it and/or modify
  6. %it under the terms of the GNU General Public License as published by
  7. %the Free Software Foundation; either version 1, or (at your option)
  8. %any later version.
  9.  
  10. %GNU CC is distributed in the hope that it will be useful,
  11. %but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. %GNU General Public License for more details.
  14.  
  15. %You should have received a copy of the GNU General Public License
  16. %along with GNU CC; see the file COPYING.  If not, write to
  17. %the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.  
  20. %In other words, you are welcome to use, share and improve this program.
  21. %You are forbidden to forbid anyone else to use, share and improve
  22. %what you give them.   Help stamp out software-hoarding!
  23.  
  24. \def\texinfoversion{2.1}
  25. \message{Loading texinfo package [Version \texinfoversion]:}
  26. \message{}
  27.  
  28. % Save some parts of plain tex whose names we will redefine.
  29.  
  30. \let\ptexlbrace=\{
  31. \let\ptexrbrace=\}
  32. \let\ptexdot=\.
  33. \let\ptexstar=\*
  34. \let\ptexend=\end
  35. \let\ptexbullet=\bullet
  36. \let\ptexb=\b
  37. \let\ptexc=\c
  38. \let\ptexi=\i
  39. \let\ptext=\t
  40. \let\ptexl=\l
  41. \let\ptexL=\L
  42.  
  43. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  44.  
  45. \message{Basics,}
  46. \chardef\other=12
  47.  
  48. \hyphenation{ap-pen-dix}
  49. \hyphenation{mini-buf-fer mini-buf-fers}
  50. \hyphenation{eshell}
  51.  
  52. % Margin to add to right of even pages, to left of odd pages.
  53. \newdimen \bindingoffset  \bindingoffset=0pt
  54. \newdimen \normaloffset   \normaloffset=\hoffset
  55. \newdimen\pagewidth \newdimen\pageheight
  56. \pagewidth=\hsize \pageheight=\vsize
  57.  
  58. %---------------------Begin change-----------------------
  59. %
  60. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  61. %
  62. \newdimen\cornerlong \newdimen\cornerthick
  63. \newdimen \topandbottommargin
  64. \newdimen \outerhsize \newdimen \outervsize
  65. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  66. \outerhsize=7in
  67. \outervsize=9.5in
  68. \topandbottommargin=.75in
  69. %
  70. %---------------------End change-----------------------
  71.  
  72. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  73. % does insertions itself, but you have to call it yourself.
  74. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  75. \def\onepageout#1{\hoffset=\normaloffset
  76. \ifodd\pageno  \advance\hoffset by \bindingoffset
  77. \else \advance\hoffset by -\bindingoffset\fi
  78. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  79.  {\let\hsize=\pagewidth \makefootline}}
  80. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  81.  
  82.  
  83. % Here is a modification of the main output routine for Near East Publications
  84. % This provides right-angle cropmarks at all four corners.
  85. % The contents of the page are centerlined into the cropmarks,
  86. % and any desired binding offset is added as an \hskip on either
  87. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  88. %
  89. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  90.          \shipout
  91.          \vbox to \outervsize{\hsize=\outerhsize
  92.                  \vbox{\line{\ewtop\hfill\ewtop}}
  93.                  \nointerlineskip
  94.                  \line{\vbox{\moveleft\cornerthick\nstop}
  95.                        \hfill
  96.                        \vbox{\moveright\cornerthick\nstop}}
  97.                  \vskip \topandbottommargin
  98.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  99.             \vbox{
  100.             {\let\hsize=\pagewidth \makeheadline}
  101.             \pagebody{#1}
  102.             {\let\hsize=\pagewidth \makefootline}}
  103.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  104.          \vskip \topandbottommargin plus1fill minus1fill
  105.                  \boxmaxdepth\cornerthick
  106.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  107.                        \hfill
  108.                        \vbox{\moveright\cornerthick\nsbot}}
  109.                  \nointerlineskip
  110.                  \vbox{\line{\ewbot\hfill\ewbot}}
  111.     }
  112.   \advancepageno 
  113.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  114. %
  115. % Do @cropmarks to get crop marks
  116. \def\cropmarks{\let\onepageout=\croppageout }
  117.  
  118. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  119. {\catcode`\@ =11
  120. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  121. \dimen@=\dp#1 \unvbox#1
  122. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  123. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  124. }
  125.  
  126. %
  127. % Here are the rules for the cropmarks.  Note that they are
  128. % offset so that the space between them is truly \outerhsize or \outervsize
  129. % (P. A. MacKay, 12 November, 1986)
  130. %
  131. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  132. \def\nstop{\vbox
  133.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  134. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  135. \def\nsbot{\vbox
  136.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  137.  
  138. % Parse an argument, then pass it to #1.
  139. % The argument can be delimited with [...] or with "..." or braces
  140. % or it can be a whole line.
  141. % #1 should be a macro which expects
  142. % an ordinary undelimited TeX argument.
  143.  
  144. \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
  145.  
  146. \def\parseargx{%
  147. \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
  148. \aftergroup \parseargline %
  149. \fi \endgroup}
  150.  
  151. {\obeyspaces %
  152. \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
  153.  
  154. \gdef\obeyedspace{\ }
  155.  
  156. \def\parseargline{\begingroup \obeylines \parsearglinex}
  157. {\obeylines %
  158. \gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
  159.  
  160. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  161.  
  162. %% These are used to keep @begin/@end levels from running away
  163. %% Call \inENV within environments (after a \begingroup)
  164. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  165. \def\ENVcheck{%
  166. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  167. \endgroup\fi} % This is not perfect, but it should reduce lossage
  168.  
  169. % @begin foo  is the same as @foo, for now.
  170. \newhelp\EMsimple{Type <Return> to continue}
  171.  
  172. \outer\def\begin{\parsearg\beginxxx}
  173.  
  174. \def\beginxxx #1{%
  175. \expandafter\ifx\csname #1\endcsname\relax
  176. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  177. \csname #1\endcsname\fi}
  178.  
  179. %% @end foo executes the definition of \Efoo.
  180. %% foo can be delimited by doublequotes or brackets.
  181.  
  182. \def\end{\parsearg\endxxx}
  183.  
  184. \def\endxxx #1{%
  185. \expandafter\ifx\csname E#1\endcsname\relax
  186. \expandafter\ifx\csname #1\endcsname\relax
  187. \errmessage{Undefined command @end #1}\else
  188. \errorE{#1}\fi\fi
  189. \csname E#1\endcsname}
  190. \def\errorE#1{
  191. {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
  192.  
  193. % Single-spacing is done by various environments.
  194.  
  195. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  196. \def\singlespace{%
  197. {\advance \baselineskip by -\singlespaceskip
  198. \kern \baselineskip}%
  199. \baselineskip=\singlespaceskip
  200. }
  201.  
  202. %% Simple single-character @ commands
  203.  
  204. % @@ prints an @
  205. % Kludge this until the fonts are right (grr).
  206. \def\@{{\sf \char '100}}
  207.  
  208. % Define @` and @' to be the same as ` and '
  209. % but suppressing ligatures.
  210. \def\`{{`}}
  211. \def\'{{'}}
  212.  
  213. % Used to generate quoted braces.
  214.  
  215. \def\mylbrace {{\tt \char '173}}
  216. \def\myrbrace {{\tt \char '175}}
  217. \let\{=\mylbrace
  218. \let\}=\myrbrace
  219.  
  220. % @: forces normal size whitespace following.
  221. \def\:{\spacefactor=1000 }
  222.  
  223. % @* forces a line break.
  224. \def\*{\hfil\break}
  225.  
  226. % @. is an end-of-sentence period.
  227. \def\.{.\spacefactor=3000 }
  228.  
  229. % @w prevents a word break
  230. \def\w #1{\hbox{#1}}
  231.  
  232. % @group ... @end group  forces ... to be all on one page.
  233.  
  234. \def\group{\begingroup% \inENV ???
  235. \def \Egroup{\egroup\endgroup}
  236. \vbox\bgroup}
  237.  
  238. % @br   forces paragraph break
  239.  
  240. \let\br = \par
  241.  
  242. % @dots{}  output some dots
  243.  
  244. \def\dots{$\ldots$}
  245.  
  246. % @page    forces the start of a new page
  247.  
  248. \def\page{\par\vfill\supereject}
  249.  
  250. % @exdent text....
  251. % outputs text on separate line in roman font, starting at standard page margin
  252.  
  253. \def\exdent{\errmessage{@exdent in filled text}}
  254.   % @lisp, etc, define \exdent locally from \internalexdent
  255.  
  256. {\obeyspaces
  257. \gdef\internalexdent{\parsearg\exdentzzz}}
  258.  
  259. \def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
  260. \advance \hsize by -\leftskip
  261. \advance \hsize by -\rightskip
  262. \leftline{{\rm#1}}}}
  263.  
  264. % @include file    insert text of that file as input.
  265.  
  266. \def\include{\parsearg\includezzz}
  267. \def\includezzz #1{{\def\thisfile{#1}\input #1
  268. }}
  269.  
  270. \def\thisfile{}
  271.  
  272. % @center line   outputs that line, centered
  273.  
  274. \def\center{\parsearg\centerzzz}
  275. \def\centerzzz #1{{\advance\hsize by -\leftskip
  276. \advance\hsize by -\rightskip
  277. \centerline{#1}}}
  278.  
  279. % @sp n   outputs n lines of vertical space
  280.  
  281. \def\sp{\parsearg\spxxx}
  282. \def\spxxx #1{\par \vskip #1\baselineskip}
  283.  
  284. % @comment ...line which is ignored...
  285. % @c is the same as @comment
  286. % @ignore ... @end ignore  is another way to write a comment
  287.  
  288. \def\comment{\parsearg \commentxxx}
  289.  
  290. \def\commentxxx #1{}
  291.  
  292. \let\c=\comment
  293.  
  294. % Prevent errors for section commands.
  295. % Used in @ignore and in failing conditionals.
  296. \def\ignoresections{%
  297. \let\chapter=\relax
  298. \let\unnumbered=\relax
  299. \let\unnumberedsec=\relax
  300. \let\unnumberedsection=\relax
  301. \let\unnumberedsubsec=\relax
  302. \let\unnumberedsubsection=\relax
  303. \let\unnumberedsubsubsec=\relax
  304. \let\unnumberedsubsubsection=\relax
  305. \let\section=\relax
  306. \let\subsec=\relax
  307. \let\subsubsec=\relax
  308. \let\subsection=\relax
  309. \let\subsubsection=\relax
  310. \let\appendix=\relax
  311. \let\appendixsec=\relax
  312. \let\appendixsection=\relax
  313. \let\appendixsubsec=\relax
  314. \let\appendixsubsection=\relax
  315. \let\appendixsubsubsec=\relax
  316. \let\appendixsubsubsection=\relax
  317. }
  318.  
  319. \def\ignore{\begingroup\ignoresections\ignorexxx}
  320. \long\def\ignorexxx #1\end ignore{\endgroup}
  321.  
  322. % Conditionals to test whether a flag is set.
  323.  
  324. \outer\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
  325.  
  326. \def\ifsetxxx #1{\endgroup
  327. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
  328. \else \let\temp=\relax \fi
  329. \temp}
  330. \def\Eifset{}
  331. \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
  332. \long\def\ifsetfailxxx #1\end ifset{\endgroup}
  333.  
  334. \outer\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
  335.  
  336. \def\ifclearxxx #1{\endgroup
  337. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
  338. \else \let\temp=\ifclearfail \fi
  339. \temp}
  340. \def\Eifclear{}
  341. \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
  342. \long\def\ifclearfailxxx #1\end ifclear{\endgroup}
  343.  
  344. % Some texinfo constructs that are trivial in tex
  345.  
  346. \def\iftex{}
  347. \def\Eiftex{}
  348. \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
  349. \long\def\ifinfoxxx #1\end ifinfo{\endgroup}
  350.  
  351. \long\def\menu #1\end menu{}
  352. \def\asis#1{#1}
  353.  
  354. \def\node{\ENVcheck\parsearg\nodezzz}
  355. \def\nodezzz#1{\nodexxx [#1,]}
  356. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  357. \let\lastnode=\relax
  358.  
  359. \def\donoderef{\ifx\lastnode\relax\else
  360. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  361. \let\lastnode=\relax}
  362.  
  363. \def\unnumbnoderef{\ifx\lastnode\relax\else
  364. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  365. \let\lastnode=\relax}
  366.  
  367. \def\appendixnoderef{\ifx\lastnode\relax\else
  368. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  369. \let\lastnode=\relax}
  370.  
  371. \let\refill=\relax
  372.   
  373. % @setfilename is done at the beginning of every texinfo file.
  374. % So open here the files we need to have open while reading the input.
  375. % This makes it possible to make a .fmt file for texinfo.
  376. \def\setfilename{%
  377.    \readauxfile
  378.    \opencontents
  379.    \openindices
  380.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  381.    \comment % Ignore the actual filename.
  382. }
  383.  
  384. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  385.  
  386. \def\inforef #1{\inforefzzz #1,,,,**}
  387. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node `\losespace#1{}'}
  388. \def\losespace #1{#1}
  389.  
  390. \message{fonts,}
  391.  
  392. % Font-change commands.
  393.  
  394. %% Try out Computer Modern fonts at \magstephalf
  395. \font\tenrm=cmr10 scaled \magstephalf
  396. \font\tentt=cmtt10 scaled \magstephalf
  397. % Instead of cmb10, you many want to use cmbx10.
  398. % cmbx10 is a prettier font on its own, but cmb10
  399. % looks better when embedded in a line with cmr10.
  400. \font\tenbf=cmb10 scaled \magstephalf 
  401. \font\tenit=cmti10 scaled \magstephalf
  402. \font\tensl=cmsl10 scaled \magstephalf
  403. \font\tensf=cmss10 scaled \magstephalf
  404. \def\li{\sf}
  405. \font\tensc=cmcsc10 scaled \magstephalf
  406.  
  407. % Fonts for @defun, etc.
  408. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  409. \let\deftt=\tentt
  410. \def\df{\let\tt=\deftt \defbf}
  411.  
  412. % Font for title
  413. \font\titlerm = cmbx10 scaled \magstep5
  414.  
  415. % Fonts for indices
  416. \font\indit=cmti9 \font\indrm=cmr9
  417. \font\indtt=cmtt9
  418. \def\indbf{\indrm} \def\indsl{\indit}
  419. \def\indexfonts{\let\it=\indit \let\sl=\indsl \let\bf=\indbf \let\rm=\indrm
  420. \let\tt=\indtt}
  421.  
  422. % Fonts for headings
  423. \font\chaprm=cmbx10 scaled \magstep3
  424. \font\chapit=cmti10 scaled \magstep3
  425. \font\chapsl=cmsl10 scaled \magstep3
  426. \font\chaptt=cmtt10 scaled \magstep3
  427. \font\chapsf=cmss10 scaled \magstep3
  428. \let\chapbf=\chaprm
  429.  
  430. \font\secrm=cmbx10 scaled \magstep2
  431. \font\secit=cmti10 scaled \magstep2
  432. \font\secsl=cmsl10 scaled \magstep2
  433. \font\sectt=cmtt10 scaled \magstep2
  434. \font\secsf=cmss10 scaled \magstep2
  435. \let\secbf=\secrm
  436.  
  437. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an fontlooked bad.
  438. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  439. % \font\ssecsl=cmsl10 scaled \magstep1
  440. % \font\ssectt=cmtt10 scaled \magstep1
  441. % \font\ssecsf=cmss10 scaled \magstep1
  442.  
  443. \font\ssecrm=cmb10 at 13pt    % Note the use of cmb rather than cmbx.
  444. \font\ssecit=cmti10 at 13pt    % Also, the size is a little larger than
  445. \font\ssecsl=cmsl10 at 13pt    % being scaled magstep1.
  446. \font\ssectt=cmtt10 at 13pt
  447. \font\ssecsf=cmss10 at 13pt
  448.  
  449. \let\ssecbf=\ssecrm
  450.  
  451. \def\textfonts{\let\rm=\tenrm\let\it=\tenit\let\sl=\tensl\let\bf=\tenbf%
  452. \let\smallcaps=\tensc\let\sf=\tensf}
  453. \def\chapfonts{\let\rm=\chaprm\let\it=\chapit\let\sl=\chapsl\let\bf=\chapbf\let\tt=\chaptt\let\sf=\chapsf}
  454. \def\secfonts{\let\rm=\secrm\let\it=\secit\let\sl=\secsl\let\bf=\secbf\let\tt=\sectt\let\sf=\secsf}
  455. \def\subsecfonts{\let\rm=\ssecrm\let\it=\ssecit\let\sl=\ssecsl\let\bf=\ssecbf\let\tt=\ssectt\let\sf=\ssecsf}
  456. % Count depth in font-changes, for error checks
  457. \newcount\fontdepth \fontdepth=0
  458.  
  459. % Font for table of contents.
  460. \font\truesecrm=cmr12
  461.  
  462. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  463. %% serif) and @ii for TeX italic
  464.  
  465. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  466. % unless the following character is such as not to need one.
  467. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  468. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  469.  
  470. \let\i=\smartitalic
  471. \let\var=\smartitalic
  472. \let\dfn=\smartitalic
  473. \let\emph=\smartitalic
  474. \let\cite=\smartitalic
  475.  
  476. \def\b#1{{\bf #1}}
  477. \let\strong=\b
  478.  
  479. \def\t#1{{\tt \rawbackslash \frenchspacing #1}\null}
  480. \let\ttfont = \t
  481. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  482. \def\samp #1{`\tclose{#1}'\null}
  483. \def\key #1{{\tt \uppercase{#1}}\null}
  484. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  485.  
  486. \let\file=\samp
  487.  
  488. % @code is a modification of @t,
  489. % which makes spaces the same size as normal in the surrounding text.
  490. \newdimen\tclosesave
  491. \newdimen\tcloserm
  492. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  493. \fontdimen2\font=\tcloserm
  494. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  495.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  496. \let\code=\tclose
  497. %\let\exp=\tclose  %Was temporary
  498.  
  499. % @kbd is like @code, except that if the argument is just one @key command, 
  500. % then @kbd has no effect.
  501.  
  502. \def\xkey{\key}
  503. \def\kbdfoo#1#2#3*{\def\one{#1}\def\three{#3}\def\threex{??}%
  504. \ifx\one\xkey\ifx\threex\three \key{#2}
  505. \else\tclose{\look}\fi
  506. \else\tclose{\look}\fi}
  507.  
  508. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??*}
  509.  
  510. \def\l#1{{\li #1}\null}        % 
  511.  
  512. \def\r#1{{\rm #1}}        % roman font
  513. \def\sc#1{{\smallcaps #1}}    % smallcaps font
  514. \def\ii#1{{\it #1}}        % italic font
  515.  
  516. \message{page headings,}
  517.  
  518. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  519. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  520.  
  521. % First the title page.  Must do @settitle before @titlepage.
  522. \font\titlerm = cmbx12 scaled \magstep2
  523. \def\titlefont#1{{\titlerm #1}}
  524.  
  525. \newtoks\realeverypar
  526. \newif\ifseenauthor
  527.  
  528. \def\titlepage{\begingroup \parindent=0pt \textfonts
  529.    \font\subtitlerm = cmr10 scaled \magstephalf
  530.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 12pt \normalbaselines}%
  531.    %
  532.    \font\authorrm = cmbx12 scaled \magstep1
  533.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  534.    %
  535.    % The first subtitle should have some space before it, but not the
  536.    % others.  They all should be ragged left.
  537. % This code caused a bug, since two groups were started, but only
  538. % one was ended.  Also, I can't see the point of this code.
  539. %   \begingroup \realeverypar = {\leftskip = 2in plus 3em minus 1em
  540. %                    \parfillskip = 0pt}%
  541. %   \everypar = {\vglue \baselineskip \the\realeverypar
  542. %                \everypar={\the\realeverypar}}%
  543.    %
  544.    % Now you can print the title using @title.
  545.    \def\title{\parsearg\titlezzz}%
  546.    \def\titlezzz##1{\leftline{\titlefont{##1}
  547.             \vskip4pt \hrule height 4pt \vskip4pt}}%
  548.    \vglue\titlepagetopglue
  549.    %
  550.    % Now you can put text using @subtitle.
  551.    \def\subtitle{\parsearg\subtitlezzz}%
  552.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  553.    %
  554.    % @author should come last, but may come many times.
  555.    \def\author{\parsearg\authorzzz}%
  556.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  557.       {\authorfont \leftline{##1}}}%
  558.    %  
  559.    % Most title ``pages'' are actually two pages long, with space
  560.    % at the top of the second.  We don't want the ragged left on the second.
  561.    \let\oldpage = \page
  562. %   \def\page{\vskip4pt \hrule height 2pt \vskip\titlepagebottomglue
  563. %      \oldpage \endgroup\hrule height0pt\relax}%
  564.    \def\page{\oldpage \hbox{}}
  565. }
  566.  
  567. \def\Etitlepage{\endgroup\page\HEADINGSon}
  568.  
  569. %%% Set up page headings and footings.
  570.  
  571. \let\thispage=\folio
  572.  
  573. \newtoks \evenheadline    % Token sequence for heading line of even pages
  574. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  575. \newtoks \evenfootline    % Token sequence for footing line of even pages
  576. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  577.  
  578. % Now make Tex use those variables
  579. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}}
  580. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}}
  581.  
  582. % Commands to set those variables.
  583. % For example, this is what  @headings on  does
  584. % @evenheading @thistitle|@thispage|@thischapter
  585. % @oddheading @thischapter|@thispage|@thistitle
  586. % @evenfooting @thisfile||
  587. % @oddfooting ||@thisfile
  588.  
  589. \def\evenheading{\parsearg\evenheadingxxx}
  590. \def\oddheading{\parsearg\oddheadingxxx}
  591. \def\everyheading{\parsearg\everyheadingxxx}
  592.  
  593. \def\evenfooting{\parsearg\evenfootingxxx}
  594. \def\oddfooting{\parsearg\oddfootingxxx}
  595. \def\everyfooting{\parsearg\everyfootingxxx}
  596.  
  597. {\catcode`\@=0 %
  598.  
  599. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  600. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  601. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  602.  
  603. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  604. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  605. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  606.  
  607. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  608. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  609. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  610. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  611.  
  612. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  613. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  614. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  615.  
  616. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  617. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  618. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  619.  
  620. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  621. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  622. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  623. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  624. %
  625. }% unbind the catcode of @.
  626.  
  627. % @headings double    turns headings on for double-sided printing.
  628. % @headings single    turns headings on for single-sided printing.
  629. % @headings off        turns them off.
  630. % @headings on        same as @headings double, retained for compatibility.
  631. % By default, they are off.
  632.  
  633. \def\headings #1 {\csname HEADINGS#1\endcsname}
  634.  
  635. \def\HEADINGSoff{
  636. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  637. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  638. \HEADINGSoff
  639. % When we turn headings on, set the page number to 1.
  640. % For double-sided printing, put current file name in lower left corner,
  641. % chapter name on inside top of right hand pages, document
  642. % title on inside top of left hand pages, and page numbers on outside top
  643. % edge of all pages.
  644. \def\HEADINGSdouble{
  645. %\pagealignmacro
  646. \global\pageno=1
  647. \global\evenfootline={\hfil}
  648. \global\oddfootline={\hfil}
  649. \global\evenheadline={\line{\folio\hfil\thistitle}}
  650. \global\oddheadline={\line{\thischapter\hfil\folio}}
  651. }
  652. % For single-sided printing, chapter title goes across top left of page,
  653. % page number on top right.
  654. \def\HEADINGSsingle{
  655. %\pagealignmacro
  656. \global\pageno=1
  657. \global\evenfootline={\hfil}
  658. \global\oddfootline={\hfil}
  659. \global\evenheadline={\line{\thischapter\hfil\folio}}
  660. \global\oddheadline={\line{\thischapter\hfil\folio}}
  661. }
  662. \def\HEADINGSon{\HEADINGSdouble}
  663.  
  664. % Subroutines used in generating headings
  665. % Produces Day Month Year style of output.
  666. \def\today{\number\day\space
  667. \ifcase\month\or
  668. January\or February\or March\or April\or May\or June\or
  669. July\or August\or September\or October\or November\or December\fi
  670. \space\number\year}
  671.  
  672. % Use this if you want the Month Day, Year style of output.
  673. %\def\today{\ifcase\month\or
  674. %January\or February\or March\or April\or May\or June\or
  675. %July\or August\or September\or October\or November\or December\fi
  676. %\space\number\day, \number\year}
  677.  
  678. % @settitle line...  specifies the title of the document, for headings
  679. % It generates no output of its own
  680.  
  681. \def\thistitle{No Title}
  682. \def\settitle{\parsearg\settitlezzz}
  683. \def\settitlezzz #1{\gdef\thistitle{#1}}
  684.  
  685. \message{tables,}
  686.  
  687. % Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
  688.  
  689. % default indentation of table text
  690. \newdimen\tableindent \tableindent=.8in
  691. % default indentation of @itemize and @enumerate text
  692. \newdimen\itemindent  \itemindent=.3in
  693. % margin between end of table item and start of table text.
  694. \newdimen\itemmargin  \itemmargin=.1in
  695.  
  696. % used internally for \itemindent minus \itemmargin
  697. \newdimen\itemmax
  698.  
  699. % Note @table and @ftable define @item, @itemx, etc., with these defs.
  700. % They also define \itemindex
  701. % to index the item name in whatever manner is desired (perhaps none).
  702.  
  703. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  704. \def\internalBitemx{\par \parsearg\itemzzz}
  705.  
  706. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  707. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  708.  
  709. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  710. \def\internalBkitemx{\par \parsearg\kitemzzz}
  711.  
  712. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}\itemzzz {#1}}
  713.  
  714. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}\itemzzz {#1}}
  715.  
  716. \def\itemzzz #1{\begingroup %
  717. \advance \hsize by -\rightskip %
  718. \advance \hsize by -\leftskip %
  719. \setbox0=\hbox{\itemfont{#1}}%
  720. \itemindex{#1}%
  721. \parskip=0in %
  722. \noindent %
  723. \ifdim \wd0>\itemmax %
  724. \vadjust{\penalty 10000}%
  725. \hbox to \hsize{\hskip -\tableindent\box0\hss}\ %
  726. \else %
  727. \hbox to 0pt{\hskip -\tableindent\box0\hss}%
  728. \fi %
  729. \endgroup %
  730. }
  731.  
  732. \def\item{\errmessage{@item while not in a table}}
  733. \def\itemx{\errmessage{@itemx while not in a table}}
  734. \def\kitem{\errmessage{@kitem while not in a table}}
  735. \def\kitemx{\errmessage{@kitemx while not in a table}}
  736. \def\xitem{\errmessage{@xitem while not in a table}}
  737. \def\xitemx{\errmessage{@xitemx while not in a table}}
  738.  
  739. %% Contains a kludge to get @end[description] to work
  740. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  741.  
  742. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  743. {\obeylines\obeyspaces%
  744. \gdef\tablex #1^^M{%
  745. \tabley\dontindex#1        \endtabley}}
  746.  
  747. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  748. {\obeylines\obeyspaces%
  749. \gdef\ftablex #1^^M{%
  750. \tabley\fnitemindex#1        \endtabley}}
  751.  
  752. \def\dontindex #1{}
  753. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  754.  
  755. {\obeyspaces %
  756. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  757. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  758.  
  759. \def\tablez #1#2#3#4#5#6{%
  760. \aboveenvbreak %
  761. \begingroup %
  762. \def\Edescription{\Etable}% Neccessary kludge.
  763. \let\itemindex=#1%
  764. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  765. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  766. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  767. \def\itemfont{#2}%
  768. \itemmax=\tableindent %
  769. \advance \itemmax by -\itemmargin %
  770. \advance \leftskip by \tableindent %
  771. \parindent = 0pt
  772. \parskip = \smallskipamount
  773. \ifdim \parskip=0pt \parskip=2pt \fi%
  774. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  775. \let\item = \internalBitem %
  776. \let\itemx = \internalBitemx %
  777. \let\kitem = \internalBkitem %
  778. \let\kitemx = \internalBkitemx %
  779. \let\xitem = \internalBxitem %
  780. \let\xitemx = \internalBxitemx %
  781. }
  782.  
  783. % This is the counter used by @enumerate, which is really @itemize
  784.  
  785. \newcount \itemno
  786.  
  787. \def\itemize{\parsearg\itemizezzz}
  788.  
  789. \def\itemizezzz #1{\itemizey {#1}{\Eitemize}}
  790.  
  791. \def\itemizey #1#2{%
  792. \aboveenvbreak %
  793. \begingroup %
  794. \itemno = 0 %
  795. \itemmax=\itemindent %
  796. \advance \itemmax by -\itemmargin %
  797. \advance \leftskip by \itemindent %
  798. \parindent = 0pt
  799. \parskip = \smallskipamount
  800. \ifdim \parskip=0pt \parskip=2pt \fi%
  801. \def#2{\endgraf\endgroup\afterenvbreak}%
  802. \def\itemcontents{#1}%
  803. \let\item=\itemizeitem}
  804.  
  805. \def\bullet{$\ptexbullet$}
  806. \def\minus{$-$}
  807.  
  808. % Set sfcode to normal for the chars that usually have another value.
  809. % These are `.?!:;,'
  810. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  811.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  812.  
  813. \def\enumerate{\itemizey{\the\itemno.}\Eenumerate\flushcr}
  814.  
  815. % Definition of @item while inside @itemize.
  816.  
  817. \def\itemizeitem{%
  818. \advance\itemno by 1
  819. {\let\par=\endgraf \smallbreak}%
  820. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  821. {\parskip=0in \hskip 0pt
  822. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  823. \vadjust{\penalty 300}}%
  824. \flushcr}
  825.  
  826. \message{indexing,}
  827. % Index generation facilities
  828.  
  829. % Define \newwrite to be identical to plain tex's \newwrite
  830. % except not \outer, so it can be used within \newindex.
  831. {\catcode`\@=11
  832. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  833.  
  834. % \newindex {foo} defines an index named foo.
  835. % It automatically defines \fooindex such that
  836. % \fooindex ...rest of line... puts an entry in the index foo.
  837. % It also defines \fooindfile to be the number of the output channel for
  838. % the file that    accumulates this index.  The file's extension is foo.
  839. % The name of an index should be no more than 2 characters long
  840. % for the sake of vms.
  841.  
  842. \def\newindex #1{
  843. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  844. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  845. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  846. \noexpand\doindex {#1}}
  847. }
  848.  
  849. % @defindex foo  ==  \newindex{foo}
  850.  
  851. \def\defindex{\parsearg\newindex}
  852.  
  853. % Define @defcodeindex, like @defindex except put all entries in @code.
  854.  
  855. \def\newcodeindex #1{
  856. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  857. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  858. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  859. \noexpand\docodeindex {#1}}
  860. }
  861.  
  862. \def\defcodeindex{\parsearg\newcodeindex}
  863.  
  864. % @synindex foo bar    makes index foo feed into index bar.
  865. % Do this instead of @defindex foo if you don't want it as a separate index.
  866. \def\synindex #1 #2 {%
  867. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  868. \noexpand\doindex {#2}}%
  869. }
  870.  
  871. % @syncodeindex foo bar   similar, but put all entries made for index foo
  872. % inside @code.
  873. \def\syncodeindex #1 #2 {%
  874. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  875. \noexpand\docodeindex {#2}}%
  876. }
  877.  
  878. % Define \doindex, the driver for all \fooindex macros.
  879. % Argument #1 is generated by the calling \fooindex macro,
  880. %  and it is "foo", the name of the index.
  881.  
  882. % \doindex just uses \parsearg; it calls \doind for the actual work.
  883. % This is because \doind is more useful to call from other macros.
  884.  
  885. % There is also \dosubind {index}{topic}{subtopic}
  886. % which makes an entry in a two-level index such as the operation index.
  887.  
  888. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  889. \def\singleindexer #1{\doind{\indexname}{#1}}
  890.  
  891. % like the previous two, but they put @code around the argument.
  892. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  893. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  894.  
  895. \def\indexdummies{%
  896. \def\bf{\realbackslash bf }%
  897. \def\rm{\realbackslash rm }%
  898. \def\sl{\realbackslash sl }%
  899. \def\dots{\realbackslash dots }%
  900. \def\copyright{\realbackslash copyright }%
  901. \def\tclose##1{\realbackslash tclose {##1}}%
  902. \def\code##1{\realbackslash code {##1}}%
  903. \def\samp##1{\realbackslash samp {##1}}%
  904. \def\r##1{\realbackslash r {##1}}%
  905. \def\i##1{\realbackslash i {##1}}%
  906. \def\b##1{\realbackslash b {##1}}%
  907. \def\cite##1{\realbackslash cite {##1}}%
  908. \def\key##1{\realbackslash key {##1}}%
  909. \def\file##1{\realbackslash file {##1}}%
  910. \def\var##1{\realbackslash var {##1}}%
  911. \def\kbd##1{\realbackslash kbd {##1}}%
  912. }
  913.  
  914. % \indexnofonts no-ops all font-change commands.
  915. % This is used when outputting the strings to sort the index by.
  916. \def\indexdummyfont#1{#1}
  917. \def\indexnofonts{%
  918. \let\r=\indexdummyfont
  919. \let\i=\indexdummyfont
  920. \let\b=\indexdummyfont
  921. \let\emph=\indexdummyfont
  922. \let\strong=\indexdummyfont
  923. \let\cite=\indexdummyfont
  924. \let\sc=\indexdummyfont
  925. %Don't no-op \tt, since it isn't a user-level command
  926. % and is used in the definitions of the actuve chars like <, >, |...
  927. %\let\tt=\indexdummyfont
  928. \let\tclose=\indexdummyfont
  929. \let\code=\indexdummyfont
  930. \let\file=\indexdummyfont
  931. \let\samp=\indexdummyfont
  932. \let\kbd=\indexdummyfont
  933. \let\key=\indexdummyfont
  934. \let\var=\indexdummyfont
  935. }
  936.  
  937. % To define \realbackslash, we must make \ not be an escape.
  938. % We must first make another character (@) an escape
  939. % so we do not become unable to do a definition.
  940.  
  941. {\catcode`\@=0 \catcode`\\=\other
  942. @gdef@realbackslash{\}}
  943.  
  944. \let\indexbackslash=0  %overridden during \printindex.
  945.  
  946. \def\doind #1#2{%
  947. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  948. \count10=\lastpenalty %
  949. \escapechar=`\\%
  950. {\let\folio=0% Expand all macros now EXCEPT \folio
  951. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  952. % so it will be output as is; and it will print as backslash in the indx.
  953. %
  954. % Now process the index-string once, with all font commands turned off,
  955. % to get the string to sort the index by.
  956. {\indexnofonts
  957. \xdef\temp1{#2}%
  958. }%
  959. % Now produce the complete index entry.  We process the index-string again,
  960. % this time with font commands expanded, to get what to print in the index.
  961. \edef\temp{%
  962. \write \csname#1indfile\endcsname{%
  963. \realbackslash entry {\temp1}{\folio}{#2}}}%
  964. \temp }%
  965. \penalty\count10}}
  966.  
  967. \def\dosubind #1#2#3{%
  968. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  969. \count10=\lastpenalty %
  970. \escapechar=`\\%
  971. {\let\folio=0%
  972. \def\rawbackslashxx{\indexbackslash}%
  973. %
  974. % Now process the index-string once, with all font commands turned off,
  975. % to get the string to sort the index by.
  976. {\indexnofonts
  977. \xdef\temp1{#2 #3}%
  978. }%
  979. % Now produce the complete index entry.  We process the index-string again,
  980. % this time with font commands expanded, to get what to print in the index.
  981. \edef\temp{%
  982. \write \csname#1indfile\endcsname{%
  983. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  984. \temp }%
  985. \penalty\count10}}
  986.  
  987. % The index entry written in the file actually looks like
  988. %  \entry {sortstring}{page}{topic}
  989. % or
  990. %  \entry {sortstring}{page}{topic}{subtopic}
  991. % The texindex program reads in these files and writes files
  992. % containing these kinds of lines:
  993. %  \initial {c}
  994. %     before the first topic whose initial is c
  995. %  \entry {topic}{pagelist}
  996. %     for a topic that is used without subtopics
  997. %  \primary {topic}
  998. %     for the beginning of a topic that is used with subtopics
  999. %  \secondary {subtopic}{pagelist}
  1000. %     for each subtopic.
  1001.  
  1002. % Define the user-accessible indexing commands 
  1003. % @findex, @vindex, @kindex, @cindex.
  1004.  
  1005. \def\findex {\fnindex}
  1006. \def\kindex {\kyindex}
  1007. \def\cindex {\cpindex}
  1008. \def\vindex {\vrindex}
  1009. \def\tindex {\tpindex}
  1010. \def\pindex {\pgindex}
  1011.  
  1012. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1013. {\obeylines %
  1014. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1015. \dosubind{cp}{#2}{#1}}}
  1016.  
  1017. % Define the macros used in formatting output of the sorted index material.
  1018.  
  1019. % This is what you call to cause a particular index to get printed.
  1020. % Write
  1021. % @unnumbered Function Index
  1022. % @printindex fn
  1023.  
  1024. \def\printindex{\parsearg\doprintindex}
  1025.  
  1026. \def\doprintindex#1{\tex %
  1027. \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1028. \catcode`\$=\other\catcode`\_=\other
  1029. \catcode`\~=\other
  1030. % The following don't help, since the chars were translated
  1031. % when the raw index was written, and their fonts were discarded
  1032. % due to \indexnofonts.
  1033. %\catcode`\"=\active
  1034. %\catcode`\^=\active
  1035. %\catcode`\_=\active
  1036. %\catcode`\|=\active
  1037. %\catcode`\<=\active
  1038. %\catcode`\>=\active
  1039. \def\indexbackslash{\rawbackslashxx}
  1040. \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1041. \begindoublecolumns
  1042. \openin 1 \jobname.#1s
  1043. \ifeof 1 \else \closein 1 \input \jobname.#1s
  1044. \fi
  1045. \enddoublecolumns
  1046. \Etex}
  1047.  
  1048. % These macros are used by the sorted index file itself.
  1049. % Change them to control the appearance of the index.
  1050.  
  1051. % Same as \bigskipamount except no shrink.
  1052. % \balancecolumns gets confused if there is any shrink.
  1053. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1054.  
  1055. \outer\def\initial #1{%
  1056. {\let\tentt=\sectt \let\sf=\sectt
  1057. \ifdim\lastskip<\initialskipamount
  1058. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1059. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1060.  
  1061. \outer\def\entry #1#2{
  1062. {\parfillskip=0in \parskip=0in \parindent=0in
  1063. \hangindent=1in \hangafter=1%
  1064. \noindent\hbox{#1}\dotfill #2\par
  1065. }}
  1066.  
  1067. \def\primary #1{\line{#1\hfil}}
  1068.  
  1069. \newskip\secondaryindent \secondaryindent=0.5cm
  1070.  
  1071. \def\secondary #1#2{
  1072. {\parfillskip=0in \parskip=0in
  1073. \hangindent =1in \hangafter=1
  1074. \noindent\hskip\secondaryindent\hbox{#1}\dotfill #2\par
  1075. }}
  1076.  
  1077. %% Define two-column mode, which is used in indexes.
  1078. %% Adapted from the TeXBook, page 416
  1079. \catcode `\@=11
  1080.  
  1081. \newbox\partialpage
  1082.  
  1083. \newdimen\doublecolumnhsize  \doublecolumnhsize = 3.11in
  1084. \newdimen\doublecolumnvsize  \doublecolumnvsize = 19.1in
  1085. \newdimen\availdimen@
  1086.  
  1087. \def\begindoublecolumns{\begingroup
  1088.   \output={\global\setbox\partialpage=\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
  1089.   \output={\doublecolumnout} \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
  1090. \def\enddoublecolumns{\output={\balancecolumns}\eject
  1091.   \endgroup \pagegoal=\vsize}
  1092.  
  1093. \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1094.   \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1095.   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1096.   \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
  1097. \def\pagesofar{\unvbox\partialpage %
  1098.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1099. %          changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
  1100.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1101. \def\balancecolumns{%
  1102. % Unset the glue.
  1103.   \setbox255=\vbox{\unvbox255}
  1104.   \dimen@=\ht255
  1105.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1106.   \divide\dimen@ by2
  1107.   \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
  1108. % If the remaining data is too big for one page,
  1109. % output one page normally, then work with what remains.
  1110.   \ifdim \dimen@>\availdimen@
  1111.    {
  1112.      \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1113.      \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1114.      \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1115.      \onepageout\pagesofar
  1116.    }
  1117. % Recompute size of what remains, in case we just output some of it.
  1118.   \dimen@=\ht255
  1119.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1120.   \divide\dimen@ by2
  1121.   \fi
  1122.   \setbox0=\vbox{\unvbox255}
  1123.   \splittopskip=\topskip
  1124.   {\vbadness=10000 \loop \global\setbox3=\copy0
  1125.     \global\setbox1=\vsplit3 to\dimen@
  1126.     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  1127.   \setbox0=\vbox to\dimen@{\unvbox1}  \setbox2=\vbox to\dimen@{\unvbox3}
  1128.   \pagesofar}
  1129.  
  1130. \catcode `\@=\other
  1131. \message{sectioning,}
  1132. % Define chapters, sections, etc.
  1133.  
  1134. \newcount \chapno
  1135. \newcount \secno
  1136. \newcount \subsecno
  1137. \newcount \subsubsecno
  1138.  
  1139. % This counter is funny since it counts through charcodes of letters A, B, ...
  1140. \newcount \appendixno  \appendixno = `\@
  1141. \def\appendixletter{\char\the\appendixno}
  1142.  
  1143. \newwrite \contentsfile
  1144. % This is called from \setfilename.
  1145. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1146.  
  1147. % Each @chapter defines this as the name of the chapter.
  1148. % page headings and footings can use it.  @section does likewise
  1149.  
  1150. \def\thischapter{} \def\thissection{}
  1151. \def\seccheck#1{\if \pageno<0 %
  1152. \errmessage{@#1 not allowed after generating table of contents}\fi
  1153. %
  1154. }
  1155.  
  1156. \def\chapternofonts{%
  1157. \let\rawbackslash=\relax%
  1158. \let\frenchspacing=\relax%
  1159. \def\char{\realbackslash char}
  1160. \def\tclose##1{\realbackslash tclose {##1}}
  1161. \def\code##1{\realbackslash code {##1}}
  1162. \def\samp##1{\realbackslash samp {##1}}
  1163. \def\r##1{\realbackslash r {##1}}
  1164. \def\i##1{\realbackslash i {##1}}
  1165. \def\b##1{\realbackslash b {##1}}
  1166. \def\cite##1{\realbackslash cite {##1}}
  1167. \def\key##1{\realbackslash key {##1}}
  1168. \def\file##1{\realbackslash file {##1}}
  1169. \def\var##1{\realbackslash var {##1}}
  1170. \def\kbd##1{\realbackslash kbd {##1}}
  1171. }
  1172.  
  1173. \outer\def\chapter{\parsearg\chapterzzz}
  1174. \def\chapterzzz #1{\seccheck{chapter}%
  1175. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1176. \chapmacro {#1}{\the\chapno}%
  1177. \gdef\thissection{#1}\gdef\thischapter{#1}%
  1178. {\chapternofonts%
  1179. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1180. \escapechar=`\\%
  1181. \write \contentsfile \temp  %
  1182. \donoderef %
  1183. }}
  1184.  
  1185. \outer\def\appendix{\parsearg\appendixzzz}
  1186. \def\appendixzzz #1{\seccheck{appendix}%
  1187. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1188. \chapmacro {#1}{Appendix \appendixletter}%
  1189. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1190. {\chapternofonts%
  1191. \edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1192. \escapechar=`\\%
  1193. \write \contentsfile \temp  %
  1194. \appendixnoderef %
  1195. }}
  1196.  
  1197. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1198. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1199. \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
  1200. \unnumbchapmacro {#1}%
  1201. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1202. {\chapternofonts%
  1203. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1204. \escapechar=`\\%
  1205. \write \contentsfile \temp  %
  1206. \unnumbnoderef %
  1207. }}
  1208.  
  1209. \outer\def\section{\parsearg\sectionzzz}
  1210. \def\sectionzzz #1{\seccheck{section}%
  1211. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1212. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1213. {\chapternofonts%
  1214. \edef\temp{{\realbackslash secentry %
  1215. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1216. \escapechar=`\\%
  1217. \write \contentsfile \temp %
  1218. \donoderef %
  1219. \penalty 10000 %
  1220. }}
  1221.  
  1222. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1223. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1224. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1225. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1226. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1227. {\chapternofonts%
  1228. \edef\temp{{\realbackslash secentry %
  1229. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1230. \escapechar=`\\%
  1231. \write \contentsfile \temp %
  1232. \appendixnoderef %
  1233. \penalty 10000 %
  1234. }}
  1235.  
  1236. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1237. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1238. \plainsecheading {#1}\gdef\thissection{#1}%
  1239. {\chapternofonts%
  1240. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1241. \escapechar=`\\%
  1242. \write \contentsfile \temp %
  1243. \unnumbnoderef %
  1244. \penalty 10000 %
  1245. }}
  1246.  
  1247. \outer\def\subsection{\parsearg\subsectionzzz}
  1248. \def\subsectionzzz #1{\seccheck{subsection}%
  1249. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1250. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1251. {\chapternofonts%
  1252. \edef\temp{{\realbackslash subsecentry %
  1253. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1254. \escapechar=`\\%
  1255. \write \contentsfile \temp %
  1256. \donoderef %
  1257. \penalty 10000 %
  1258. }}
  1259.  
  1260. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1261. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1262. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1263. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1264. {\chapternofonts%
  1265. \edef\temp{{\realbackslash subsecentry %
  1266. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1267. \escapechar=`\\%
  1268. \write \contentsfile \temp %
  1269. \appendixnoderef %
  1270. \penalty 10000 %
  1271. }}
  1272.  
  1273. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1274. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1275. \plainsecheading {#1}\gdef\thissection{#1}%
  1276. {\chapternofonts%
  1277. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1278. \escapechar=`\\%
  1279. \write \contentsfile \temp %
  1280. \unnumbnoderef %
  1281. \penalty 10000 %
  1282. }}
  1283.  
  1284. \outer\def\subsubsection{\parsearg\subsubsectionzzz}
  1285. \def\subsubsectionzzz #1{\seccheck{subsubsection}%
  1286. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1287. \subsubsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1288. {\chapternofonts%
  1289. \edef\temp{{\realbackslash subsubsecentry %
  1290. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1291. \escapechar=`\\%
  1292. \write \contentsfile \temp %
  1293. \donoderef %
  1294. \penalty 10000 %
  1295. }}
  1296.  
  1297. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1298. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1299. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1300. \subsubsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1301. {\chapternofonts%
  1302. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1303. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1304. \escapechar=`\\%
  1305. \write \contentsfile \temp %
  1306. \appendixnoderef %
  1307. \penalty 10000 %
  1308. }}
  1309.  
  1310. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1311. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1312. \plainsecheading {#1}\gdef\thissection{#1}%
  1313. {\chapternofonts%
  1314. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1315. \escapechar=`\\%
  1316. \write \contentsfile \temp %
  1317. \unnumbnoderef %
  1318. \penalty 10000 %
  1319. }}
  1320.  
  1321. % These are variants which are not "outer", so they can appear in @ifinfo.
  1322. \def\infounnumbered{\parsearg\unnumberedzzz}
  1323. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1324. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1325. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1326.  
  1327. \def\infoappendix{\parsearg\appendixzzz}
  1328. \def\infoappendixsec{\parsearg\appendixseczzz}
  1329. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1330. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1331.  
  1332. \def\infochapter{\parsearg\chapterzzz}
  1333. \def\infosection{\parsearg\sectionzzz}
  1334. \def\infosubsection{\parsearg\subsectionzzz}
  1335. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1336.  
  1337. % Define @majorheading, @heading and @subheading
  1338.  
  1339. \def\majorheading #1{%
  1340. {\advance\chapheadingskip by 10pt \chapbreak }%
  1341. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1342.  
  1343. \def\chapheading #1{\chapbreak %
  1344. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1345.  
  1346. \def\heading{\parsearg\secheadingi}
  1347.  
  1348. % These macros generate a chapter, section, etc. heading only
  1349. % (including whitespace, linebreaking, etc. around it),
  1350. % given all the information in convenient, parsed form.
  1351.  
  1352. %%% Args are the skip and penalty (usually negative)
  1353. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1354.  
  1355. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1356.  
  1357. %%% Define plain chapter starts, and page on/off switching for it
  1358. % Parameter controlling skip before chapter headings (if needed)
  1359.  
  1360. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1361.  
  1362. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1363. \def\chappager{\par\vfill\supereject}
  1364. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1365.  
  1366. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1367.  
  1368. \def\CHAPPAGoff{
  1369. \global\let\pchapsepmacro=\chapbreak
  1370. \global\let\pagealignmacro=\chappager}
  1371.  
  1372. \def\CHAPPAGon{
  1373. \global\let\pchapsepmacro=\chappager
  1374. \global\let\pagealignmacro=\chappager
  1375. \global\def\HEADINGSon{\HEADINGSsingle}}
  1376.  
  1377. \def\CHAPPAGodd{
  1378. \global\let\pchapsepmacro=\chapoddpage
  1379. \global\let\pagealignmacro=\chapoddpage
  1380. \global\def\HEADINGSon{\HEADINGSdouble}}
  1381.  
  1382. \CHAPPAGon
  1383.  
  1384. \def\CHAPFplain{
  1385. \global\let\chapmacro=\chfplain
  1386. \global\let\unnumbchapmacro=\unnchfplain}
  1387.  
  1388. \def\chfplain #1#2{%
  1389. \pchapsepmacro %
  1390. {\chapfonts \line{\rm #2.\enspace #1\hfill}}\bigskip \par\penalty 5000 %
  1391. }
  1392.  
  1393. \def\unnchfplain #1{%
  1394. \pchapsepmacro %
  1395. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1396. }
  1397. \CHAPFplain % The default
  1398.  
  1399. \def\unnchfopen #1{%
  1400. \chapoddpage {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1401. }
  1402.  
  1403. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1404. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1405. \par\penalty 5000 %
  1406. }
  1407.  
  1408. \def\CHAPFopen{
  1409. \global\let\chapmacro=\chfopen
  1410. \global\let\unnumbchapmacro=\unnchfopen}
  1411.  
  1412. % Parameter controlling skip before section headings.
  1413.  
  1414. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1415. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1416.  
  1417. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1418. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1419.  
  1420.  
  1421. % Section fonts are the base font at magstep2, which produces
  1422. % a size a bit more than 14 points in the default situation.    
  1423.  
  1424. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1425. \def\plainsecheading #1{\secheadingi {#1}}
  1426. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1427. \secheadingbreak}%
  1428. {\secfonts \line{\rm #1\hfill}}%
  1429. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1430.  
  1431.  
  1432. % Subsection fonts are the base font at magstep1, 
  1433. % which produces a size of 12 points.
  1434.  
  1435. \def\subsecheading #1#2#3#4{{\advance \subsecheadingskip by \parskip %
  1436. \subsecheadingbreak}%
  1437. {\subsecfonts \line{\rm#2.#3.#4\enspace #1\hfill}}%
  1438. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1439.  
  1440. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1441.                   % Perhaps make sssec fonts scaled
  1442.                   % magstep half
  1443. \def\subsubsecheading #1#2#3#4#5{{\advance \subsecheadingskip by \parskip %
  1444. \subsecheadingbreak}%
  1445. {\subsubsecfonts \line{\rm#2.#3.#4.#5\enspace #1\hfill}}%
  1446. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1447.  
  1448.  
  1449. \message{toc printing,}
  1450.  
  1451. % Finish up the main text and prepare to read what we've written
  1452. % to \contentsfile.
  1453.  
  1454. \def\startcontents#1{%
  1455.    \ifnum \pageno>0
  1456.       \pagealignmacro
  1457.       \immediate\closeout \contentsfile
  1458.       \pageno = -1        % Request roman numbered pages.
  1459.    \fi
  1460.    \unnumbchapmacro{#1}\def\thischapter{#1}%
  1461.    \begingroup           % Set up to handle contents files properly.
  1462.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1463.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1464.       \advance\hsize by -1in    % Don't use the full line length.
  1465. }
  1466.  
  1467.   
  1468. % Normal (long) toc.
  1469. \outer\def\contents{%
  1470.    \startcontents{Table of Contents}%
  1471.       \input \jobname.toc
  1472.    \endgroup
  1473.    \vfill \eject
  1474. }
  1475.  
  1476. % And just the chapters.
  1477. \outer\def\summarycontents{%
  1478.    \startcontents{Short Contents}%
  1479.       %
  1480.       \let\chapentry = \shortchapentry
  1481.       \let\unnumbchapentry = \shortunnumberedentry
  1482.       % We want a true roman here for the page numbers.
  1483.       \secfonts \let\rm = \truesecrm \rm
  1484.       \advance\baselineskip by 1pt % Open it up a little.
  1485.       \def\secentry ##1##2##3##4{}
  1486.       \def\unnumbsecentry ##1##2{}
  1487.       \def\subsecentry ##1##2##3##4##5{}
  1488.       \def\unnumbsubsecentry ##1##2{}
  1489.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1490.       \def\unnumbsubsubsecentry ##1##2{}
  1491.       \input \jobname.toc
  1492.    \endgroup
  1493.    \vfill \eject
  1494. }
  1495. \let\shortcontents = \summarycontents
  1496.  
  1497. % These macros generate individual entries in the table of contents.
  1498. % The first argument is the chapter or section name.
  1499. % The last argument is the page number.
  1500. % The arguments in between are the chapter number, section number, ...
  1501.  
  1502. % Chapter-level things, for both the long and short contents.
  1503. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1504. \def\shortchapentry#1#2#3{%
  1505.    \line{{#2\labelspace #1}\dotfill\doshortpageno{#3}}%
  1506. }
  1507.  
  1508. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1509. \def\shortunnumberedentry#1#2{%
  1510.    \line{#1\dotfill\doshortpageno{#2}}%
  1511. }
  1512.  
  1513. % Sections.
  1514. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1515. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1516.  
  1517. % Subsections.
  1518. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1519. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1520.  
  1521. % And subsubsections.
  1522. \def\subsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1523. \def\unnumbsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1524.  
  1525.  
  1526. % This parameter controls the indentation of the various levels.
  1527. \newdimen\tocindent \tocindent = 3pc
  1528.  
  1529. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1530. % page number.
  1531. %
  1532. % If the toc has to be broken over pages, we would want to be at chapters 
  1533. % if at all possible; hence the \penalty.
  1534. \def\dochapentry#1#2{%
  1535.    \penalty-300 \vskip\baselineskip
  1536.    \line{\chapentryfonts #1\dotfill \dopageno{#2}}%
  1537.    \nobreak\vskip .25\baselineskip
  1538. }
  1539.  
  1540. \def\dosecentry#1#2{%
  1541.    \line{\secentryfonts \hskip\tocindent #1\dotfill \dopageno{#2}}%
  1542. }
  1543.  
  1544. \def\dosubsecentry#1#2{%
  1545.    \line{\subsecentryfonts \hskip2\tocindent #1\dotfill \dopageno{#2}}%
  1546. }
  1547.  
  1548. \def\dosubsubsecentry#1#2{%
  1549.    \line{\subsubsecentryfonts \hskip3\tocindent #1\dotfill \dopageno{#2}}%
  1550. }
  1551.  
  1552. % Space between chapter (or whatever) number and the title.
  1553. \def\labelspace{\hskip1em \relax}
  1554.  
  1555. \def\dopageno#1{{\rm #1}}
  1556. \def\doshortpageno#1{{\rm #1}}
  1557.  
  1558. \def\chapentryfonts{\secfonts \rm}
  1559. \def\secentryfonts{\textfonts}
  1560. \let\subsecentryfonts = \textfonts
  1561. \let\subsubsecentryfonts = \textfonts
  1562.  
  1563.  
  1564. \message{environments,}
  1565.  
  1566. % Since these characters are used in examples, it should be an even number of 
  1567. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  1568. % Furthermore, these definitions must come after we define our fonts.
  1569. \newbox\dblarrowbox    \newbox\longdblarrowbox
  1570. \newbox\pushcharbox    \newbox\bullbox
  1571. \newbox\equivbox       \newbox\errorbox
  1572.  
  1573. \let\ptexequiv = \equiv
  1574.  
  1575. {\tentt
  1576. \global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  1577. \global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  1578. \global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  1579. \global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  1580. % Adapted from the manmac format (p.420 of TeXbook)
  1581. \global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  1582.                                       depth .1ex\hfil}
  1583. }
  1584.  
  1585. \def\point{$\star$}
  1586.  
  1587. \def\result{\leavevmode\raise.15ex\copy\dblarrowbox}
  1588. \def\expansion{\leavevmode\raise.1ex\copy\longdblarrowbox}
  1589. \def\print{\leavevmode\lower.1ex\copy\pushcharbox}
  1590.  
  1591. \def\equiv{\leavevmode\lower.1ex\copy\equivbox}
  1592.  
  1593. % Does anyone really want this?
  1594. % \def\bull{\leavevmode\copy\bullbox}
  1595.  
  1596. % Adapted from the TeXbook's \boxit.
  1597. \dimen0 = 3em % Width of the box.
  1598. \dimen2 = .55pt % Thickness of rules
  1599. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  1600. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  1601.  
  1602. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  1603.    \vbox{\hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  1604.       \advance\hsize by -2\dimen2 % Rules.
  1605.       \hrule height\dimen2
  1606.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  1607.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  1608.          \kern3pt\vrule width\dimen2}% Space to right.
  1609.       \hrule height\dimen2}
  1610.     \hfil}
  1611.  
  1612. % The @error{} command.
  1613. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  1614.  
  1615. % @tex ... @end tex    escapes into raw Tex temporarily.
  1616. % One exception: @ is still an escape character, so that @end tex works.
  1617. % But \@ or @@ will get a plain tex @ character.
  1618.  
  1619. \def\tex{\begingroup
  1620. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  1621. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  1622. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  1623. \catcode `\%=14
  1624. \catcode`\"=12
  1625. \catcode`\==12
  1626. \catcode`\|=12
  1627. \catcode`\<=12
  1628. \catcode`\>=12
  1629. \escapechar=`\\
  1630. %
  1631. \let\{=\ptexlbrace
  1632. \let\}=\ptexrbrace
  1633. \let\.=\ptexdot
  1634. \let\*=\ptexstar
  1635. \def\@={@}%
  1636. \let\bullet=\ptexbullet
  1637. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  1638. \let\L=\ptexL
  1639. %
  1640. \let\Etex=\endgroup}
  1641.  
  1642. % Define @lisp ... @endlisp.
  1643. % @lisp does a \begingroup so it can rebind things,
  1644. % including the definition of @endlisp (which normally is erroneous).
  1645.  
  1646. % Amount to narrow the margins by for @lisp.
  1647. \newskip\lispnarrowing \lispnarrowing=0.4in
  1648.  
  1649. % This is the definition that ^M gets inside @lisp
  1650. % phr: changed space to \null, to avoid overfull hbox problems.
  1651. {\obeyspaces%
  1652. \gdef\lisppar{\null\endgraf}}
  1653.  
  1654. % Cause \obeyspaces to make each Space cause a word-separation
  1655. % rather than the default which is that it acts punctuation.
  1656. % This is because space in tt font looks funny.
  1657. {\obeyspaces %
  1658. \gdef\sepspaces{\def {\ }}}
  1659.  
  1660. \newskip\aboveenvskipamount \aboveenvskipamount= 0pt
  1661. \def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
  1662. \endgraf \ifdim\lastskip<\aboveenvskipamount
  1663. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
  1664.  
  1665. \def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
  1666. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
  1667.  
  1668. \def\lisp{\aboveenvbreak\begingroup\inENV %This group ends at the end of the @lisp body
  1669. \hfuzz=12truept % Don't be fussy
  1670. % Make spaces be word-separators rather than space tokens.
  1671. \sepspaces %
  1672. % Single space lines
  1673. \singlespace %
  1674. % The following causes blank lines not to be ignored
  1675. % by adding a space to the end of each line.
  1676. \let\par=\lisppar
  1677. \def\Elisp{\endgroup\afterenvbreak}%
  1678. \parskip=0pt
  1679. \advance \leftskip by \lispnarrowing
  1680. \parindent=0pt
  1681. \let\exdent=\internalexdent
  1682. \obeyspaces \obeylines \tt \rawbackslash
  1683. \def\next##1{}\next}
  1684.  
  1685.  
  1686. \let\example=\lisp
  1687. \def\Eexample{\Elisp}
  1688.  
  1689. \let\smallexample=\lisp
  1690. \def\Esmallexample{\Elisp}
  1691.  
  1692. % Macro for 9 pt. examples, necessary to print with 5" lines.
  1693. % From Pavel@xerox.  This is not really used unless the
  1694. % @smallbook command is given.
  1695.  
  1696. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  1697. %            This group ends at the end of the @lisp body
  1698. \hfuzz=12truept % Don't be fussy
  1699. % Make spaces be word-separators rather than space tokens.
  1700. \sepspaces %
  1701. % Single space lines
  1702. \singlespace %
  1703. % The following causes blank lines not to be ignored
  1704. % by adding a space to the end of each line.
  1705. \let\par=\lisppar
  1706. \def\Esmalllisp{\endgroup\afterenvbreak}%
  1707. \parskip=0pt
  1708. \advance \leftskip by \lispnarrowing
  1709. \parindent=0pt
  1710. \let\exdent=\internalexdent
  1711. \obeyspaces \obeylines \ninett \rawbackslash
  1712. \def\next##1{}\next}
  1713.  
  1714. % This is @display; same as @lisp except use roman font.
  1715.  
  1716. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  1717. \aboveenvbreak
  1718. % Make spaces be word-separators rather than space tokens.
  1719. \sepspaces %
  1720. % Single space lines
  1721. \singlespace %
  1722. % The following causes blank lines not to be ignored
  1723. % by adding a space to the end of each line.
  1724. \let\par=\lisppar
  1725. \def\Edisplay{\endgroup\afterenvbreak}%
  1726. \parskip=0pt
  1727. \advance \leftskip by \lispnarrowing
  1728. \parindent=0pt
  1729. \let\exdent=\internalexdent
  1730. \obeyspaces \obeylines
  1731. \def\next##1{}\next}
  1732.  
  1733. % This is @format; same as @lisp except use roman font and don't narrow margins
  1734.  
  1735. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  1736. \aboveenvbreak
  1737. % Make spaces be word-separators rather than space tokens.
  1738. \sepspaces %
  1739. \singlespace %
  1740. % The following causes blank lines not to be ignored
  1741. % by adding a space to the end of each line.
  1742. \let\par=\lisppar
  1743. \def\Eformat{\endgroup\afterenvbreak}
  1744. \parskip=0pt \parindent=0pt
  1745. \obeyspaces \obeylines
  1746. \def\next##1{}\next}
  1747.  
  1748. % @flushleft and @flushright
  1749.  
  1750. \def\flushleft{\begingroup\inENV %This group ends at the end of the @format body
  1751. \aboveenvbreak
  1752. % Make spaces be word-separators rather than space tokens.
  1753. \sepspaces %
  1754. % The following causes blank lines not to be ignored
  1755. % by adding a space to the end of each line.
  1756. % This also causes @ to work when the directive name
  1757. % is terminated by end of line.
  1758. \let\par=\lisppar
  1759. \def\Eflushleft{\endgroup\afterenvbreak}%
  1760. \parskip=0pt \parindent=0pt
  1761. \obeyspaces \obeylines
  1762. \def\next##1{}\next}
  1763.  
  1764. \def\flushright{\begingroup\inENV %This group ends at the end of the @format body
  1765. \aboveenvbreak
  1766. % Make spaces be word-separators rather than space tokens.
  1767. \sepspaces %
  1768. % The following causes blank lines not to be ignored
  1769. % by adding a space to the end of each line.
  1770. % This also causes @ to work when the directive name
  1771. % is terminated by end of line.
  1772. \let\par=\lisppar
  1773. \def\Eflushright{\endgroup\afterenvbreak}%
  1774. \parskip=0pt \parindent=0pt
  1775. \advance \leftskip by 0pt plus 1fill
  1776. \obeyspaces \obeylines
  1777. \def\next##1{}\next}
  1778.  
  1779. % @quotation - narrow the margins.
  1780.  
  1781. \def\quotation{\begingroup\inENV %This group ends at the end of the @quotation body
  1782. {\parskip=0pt  % because we will skip by \parskip too, later
  1783. \aboveenvbreak}%
  1784. \singlespace
  1785. \parindent=0pt
  1786. \def\Equotation{\par\endgroup\afterenvbreak}%
  1787. \advance \rightskip by \lispnarrowing 
  1788. \advance \leftskip by \lispnarrowing}
  1789.  
  1790. \message{defuns,}
  1791. % Define formatter for defuns
  1792. % First, allow user to change definition object font (\df) internally
  1793. \def\setdeffont #1 {\csname DEF#1\endcsname}
  1794.  
  1795. \newskip\defbodyindent \defbodyindent=.4in
  1796. \newskip\defargsindent \defargsindent=50pt
  1797. \newskip\deftypemargin \deftypemargin=12pt
  1798. \newskip\deflastargmargin \deflastargmargin=18pt
  1799.  
  1800. \newcount\parencount
  1801. % define \functionparens, which makes ( and ) and & do special things.
  1802. % \functionparens affects the group it is contained in.
  1803. \def\activeparens{%
  1804. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  1805. \catcode`\[=\active \catcode`\]=\active}
  1806. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  1807. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  1808. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  1809.  
  1810. % Definitions of (, ) and & used in args for functions.
  1811. % This is the definition of ( outside of all parentheses.
  1812. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  1813. \global\advance\parencount by 1 }
  1814. %
  1815. % This is the definition of ( when already inside a level of parens.
  1816. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  1817. %
  1818. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  1819. % also in that case restore the outer-level definition of (.
  1820. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  1821. \global\advance \parencount by -1 }
  1822. % If we encounter &foo, then turn on ()-hacking afterwards
  1823. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  1824. %
  1825. \gdef\normalparens{\boldbrax\let&=\ampnr}
  1826. } % End of definition inside \activeparens
  1827. %% These parens (in \boldbrax) actually are a little bolder than the
  1828. %% contained text.  This is especially needed for [ and ]
  1829. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  1830. \def\lbrb{{\tt\char`\[}} \def\rbrb{{\tt\char`\]}}
  1831.  
  1832. % First, defname, which formats the header line itself.
  1833. % #1 should be the function name.
  1834. % #2 should be the type of definition, such as "Function".
  1835.  
  1836. \def\defname #1#2{%
  1837. \leftskip = 0in  %
  1838. \noindent        %
  1839. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  1840. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  1841. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  1842. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  1843. % Now output arg 2 ("Function" or some such)
  1844. % ending at \deftypemargin from the right margin,
  1845. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  1846. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}%
  1847. \tolerance=10000 \hbadness=10000    % Make all lines underfull and no complaints
  1848. {\df #1}\enskip        % Generate function name
  1849. }
  1850.  
  1851. % Actually process the body of a definition
  1852. % #1 should be the terminating control sequence, such as \Edefun.
  1853. % #2 should be the "another name" control sequence, such as \defunx.
  1854. % #3 should be the control sequence that actually processes the header,
  1855. %    such as \defunheader.
  1856.  
  1857. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  1858. \medbreak %
  1859. % Define the end token that this defining construct specifies
  1860. % so that it will exit this group.
  1861. \def#1{\endgraf\endgroup\medbreak}%
  1862. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  1863. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1864. \begingroup\obeylines\activeparens\spacesplit#3}
  1865.  
  1866. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  1867. \medbreak %
  1868. % Define the end token that this defining construct specifies
  1869. % so that it will exit this group.
  1870. \def#1{\endgraf\endgroup\medbreak}%
  1871. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  1872. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1873. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  1874.  
  1875. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  1876. \medbreak %
  1877. % Define the end token that this defining construct specifies
  1878. % so that it will exit this group.
  1879. \def#1{\endgraf\endgroup\medbreak}%
  1880. \def#2##1 ##2 {\def#4{##1}%
  1881. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  1882. \parindent=0in \leftskip=\defbodyindent %
  1883. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  1884.  
  1885. % Split up #2 at the first space token.
  1886. % call #1 with two arguments:
  1887. %  the first is all of #2 before the space token,
  1888. %  the second is all of #2 after that space token.
  1889. % If #2 contains no space token, all of it is passed as the first arg
  1890. % and the second is passed as empty.
  1891.  
  1892. {\obeylines
  1893. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  1894. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  1895. \ifx\relax #3%
  1896. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  1897.  
  1898. % So much for the things common to all kinds of definitions.
  1899.  
  1900. % Define @defun.
  1901.  
  1902. % First, define the processing that is wanted for arguments of \defun
  1903. % Use this to expand the args and terminate the paragraph they make up
  1904.  
  1905. \def\defunargs #1{\functionparens \sl
  1906. % Expand, preventing hyphenation at `-' chars.
  1907. % Note that groups don't affect changes in \hyphenchar.
  1908. \hyphenchar\sl=0
  1909. #1%
  1910. \hyphenchar\sl=45
  1911. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  1912. \interlinepenalty=10000
  1913. \endgraf\penalty10000\vskip -\parskip }
  1914.  
  1915. % Do complete processing of one @defun or @defunx line already parsed.
  1916.  
  1917. % @deffn Command forward-char nchars
  1918.  
  1919. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  1920.  
  1921. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  1922. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup}
  1923.  
  1924. % @defun == @deffn Function
  1925.  
  1926. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  1927.  
  1928. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  1929. \begingroup\defname {#1}{Function}%
  1930. \defunargs {#2}\endgroup %
  1931. }
  1932.  
  1933. % @defmac == @deffn Macro
  1934.  
  1935. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  1936.  
  1937. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  1938. \begingroup\defname {#1}{Macro}%
  1939. \defunargs {#2}\endgroup %
  1940. }
  1941.  
  1942. % @defspec == @deffn Special Form
  1943.  
  1944. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  1945.  
  1946. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  1947. \begingroup\defname {#1}{Special form}%
  1948. \defunargs {#2}\endgroup %
  1949. }
  1950.  
  1951. % This definition is run if you use @defunx
  1952. % anywhere other than immediately after a @defun or @defunx.
  1953.  
  1954. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  1955. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  1956. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  1957. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  1958.  
  1959. % @defmethod, and so on
  1960.  
  1961. % @defop {Funny Method} foo-class frobnicate argument
  1962.  
  1963. \def\defop #1 {\def\defoptype{#1}%
  1964. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  1965.  
  1966. \def\defopheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  1967. \begingroup\defname {#2}{\defoptype{} on #1}%
  1968. \defunargs {#3}\endgroup %
  1969. }
  1970.  
  1971. % @defmethod == @defop Method
  1972.  
  1973. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  1974.  
  1975. \def\defmethodheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% entry in function index
  1976. \begingroup\defname {#2}{Operation on #1}%
  1977. \defunargs {#3}\endgroup %
  1978. }
  1979.  
  1980. % @defcv {Class Option} foo-class foo-flag
  1981.  
  1982. \def\defcv #1 {\def\defcvtype{#1}%
  1983. \defopparsebody\Edefcv\defcvx\defcvheader\defcvtype}
  1984.  
  1985. \def\defcvarheader #1#2#3{%
  1986. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  1987. \begingroup\defname {#2}{\defcvtype of #1}%
  1988. \defvarargs {#3}\endgroup %
  1989. }
  1990.  
  1991. % @defivar == @defcv {Instance Variable}
  1992.  
  1993. \def\defivar{\defmethparsebody\Edefivar\defivarx\defivarheader}
  1994.  
  1995. \def\defivarheader #1#2#3{%
  1996. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  1997. \begingroup\defname {#2}{Instance variable of #1}%
  1998. \defvarargs {#3}\endgroup %
  1999. }
  2000.  
  2001. % These definitions are run if you use @defmethodx, etc.,
  2002. % anywhere other than immediately after a @defmethod, etc.
  2003.  
  2004. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2005. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2006. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2007. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2008.  
  2009. % Now @defvar
  2010.  
  2011. % First, define the processing that is wanted for arguments of @defvar.
  2012. % This is actually simple: just print them in roman.
  2013. % This must expand the args and terminate the paragraph they make up
  2014. \def\defvarargs #1{\normalparens #1%
  2015. \interlinepenalty=10000
  2016. \endgraf\penalty 10000\vskip -\parskip}
  2017.  
  2018. % @defvr Counter foo-count
  2019.  
  2020. \def\defvr{\defmethparsebody\Edefvr\defvrx\defvrheader}
  2021.  
  2022. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2023. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2024.  
  2025. % @defvar == @defvr Variable
  2026.  
  2027. \def\defvar{\defparsebody\Edefvar\defvarx\defvarheader}
  2028.  
  2029. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2030. \begingroup\defname {#1}{Variable}%
  2031. \defvarargs {#2}\endgroup %
  2032. }
  2033.  
  2034. % @defopt == @defvr {User Option}
  2035.  
  2036. \def\defopt{\defparsebody\Edefopt\defoptx\defoptheader}
  2037.  
  2038. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2039. \begingroup\defname {#1}{User Option}%
  2040. \defvarargs {#2}\endgroup %
  2041. }
  2042.  
  2043. % This definition is run if you use @defvarx
  2044. % anywhere other than immediately after a @defvar or @defvarx.
  2045.  
  2046. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2047. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2048. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2049.  
  2050. % Now define @deftp
  2051. % Args are printed in bold, a slight difference from @defvar.
  2052.  
  2053. \def\deftpargs #1{\bf \defvarargs{#1}}
  2054.  
  2055. % @deftp Class window height width ...
  2056.  
  2057. \def\deftp{\defmethparsebody\Edeftp\deftpx\deftpheader}
  2058.  
  2059. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2060. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2061.  
  2062. % This definition is run if you use @deftpx, etc
  2063. % anywhere other than immediately after a @deftp, etc.
  2064.  
  2065. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2066.  
  2067. \message{cross reference,}
  2068. % Define cross-reference macros
  2069. \newwrite \auxfile
  2070.  
  2071. % \setref{foo} defines a cross-reference point named foo.
  2072.  
  2073. \def\setref#1{%
  2074. \dosetq{#1-pg}{Ypagenumber}%
  2075. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2076.  
  2077. \def\unnumbsetref#1{%
  2078. \dosetq{#1-pg}{Ypagenumber}%
  2079. \dosetq{#1-snt}{Ynothing}}
  2080.  
  2081. \def\appendixsetref#1{%
  2082. \dosetq{#1-pg}{Ypagenumber}%
  2083. \dosetq{#1-snt}{Yappendixletterandtype}}
  2084.  
  2085. % \xref and \pxref generate cross references to specified points.
  2086.  
  2087. \def\pxref #1{see \xrefX [#1,,,,,,,]}
  2088. \def\xref #1{See \xrefX [#1,,,,,,,]}
  2089. \def\ref #1{\xrefX [#1,,,,,,,]}
  2090. \def\xrefX [#1,#2,#3,#4,#5,#6]{%
  2091. \setbox1=\hbox{\i{\losespace#5{}}}%
  2092. \setbox0=\hbox{\losespace#3{}}%
  2093. \ifdim \wd0 =0pt \setbox0=\hbox{\losespace#1{}}\fi%
  2094. \ifdim \wd1 >0pt%
  2095. section `\unhbox0' in \unhbox1%
  2096. \else%
  2097. \refx{#1-snt}{} [\unhbox0], page\tie \refx{#1-pg}{}%
  2098. \fi }
  2099.  
  2100. % \dosetq is the interface for calls from other macros
  2101.  
  2102. \def\dosetq #1#2{{\let\folio=0%
  2103. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2104. \next}}
  2105.  
  2106. % \internalsetq {foo}{page} expands into CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2107. % When the aux file is read, ' is the escape character
  2108.  
  2109. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2110.  
  2111. % Things to be expanded by \internalsetq
  2112.  
  2113. \def\Ypagenumber{\folio}
  2114.  
  2115. \def\Ynothing{}
  2116.  
  2117. \def\Ysectionnumberandtype{%
  2118. \ifnum\secno=0 chapter\xreftie\the\chapno %
  2119. \else \ifnum \subsecno=0 section\xreftie\the\chapno.\the\secno %
  2120. \else \ifnum \subsubsecno=0 %
  2121. section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2122. \else %
  2123. section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2124. \fi \fi \fi }
  2125.  
  2126. \def\Yappendixletterandtype{%
  2127. \ifnum\secno=0 appendix\xreftie'char\the\appendixno %
  2128. \else \ifnum \subsecno=0 section\xreftie'char\the\appendixno.\the\secno %
  2129. \else \ifnum \subsubsecno=0 %
  2130. section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2131. \else %
  2132. section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2133. \fi \fi \fi }
  2134.  
  2135. \gdef\xreftie{'tie}
  2136.  
  2137. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2138. % If its value is nonempty, SUFFIX is output afterward.
  2139.  
  2140. \def\refx#1#2{%
  2141. {%
  2142. \expandafter\ifx\csname X#1\endcsname\relax
  2143. % If not defined, say something at least.
  2144. \expandafter\gdef\csname X#1\endcsname {$\langle$un\-def\-in\-ed$\rangle$}#2%
  2145. \message {WARNING: Cross-reference "#1" used but not yet defined}%
  2146. \message {}%
  2147. \fi %
  2148. \setbox0=\hbox{\csname X#1\endcsname}%It's defined, so just use it.
  2149. \ifdim\wd0>0pt \unhbox0{}#2\fi
  2150. }}
  2151.  
  2152. % Read the last existing aux file, if any.  No error if none exists.
  2153.  
  2154. % This is the macro invoked by entries in the aux file.
  2155. \def\xrdef #1#2{
  2156. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2157.  
  2158. \def\readauxfile{%
  2159. \begingroup
  2160. \catcode `\^^@=\other
  2161. \catcode `\=\other
  2162. \catcode `\=\other
  2163. \catcode `\^^C=\other
  2164. \catcode `\^^D=\other
  2165. \catcode `\^^E=\other
  2166. \catcode `\^^F=\other
  2167. \catcode `\^^G=\other
  2168. \catcode `\^^H=\other
  2169. \catcode `\ =\other
  2170. \catcode `\^^L=\other
  2171. \catcode `\=\other
  2172. \catcode `\=\other
  2173. \catcode `\=\other
  2174. \catcode `\=\other
  2175. \catcode `\=\other
  2176. \catcode `\=\other
  2177. \catcode `\=\other
  2178. \catcode `\=\other
  2179. \catcode `\=\other
  2180. \catcode `\=\other
  2181. \catcode `\=\other
  2182. \catcode `\=\other
  2183. \catcode `\=\other
  2184. \catcode `\^^[=\other
  2185. \catcode `\^^\=\other
  2186. \catcode `\^^]=\other
  2187. \catcode `\^^^=\other
  2188. \catcode `\^^_=\other
  2189. \catcode `\@=\other
  2190. \catcode `\^=\other
  2191. \catcode `\~=\other
  2192. \catcode `\[=\other
  2193. \catcode `\]=\other
  2194. \catcode`\"=\other
  2195. \catcode`\_=\other
  2196. \catcode`\|=\other
  2197. \catcode`\<=\other
  2198. \catcode`\>=\other
  2199. \catcode `\$=\other
  2200. \catcode `\#=\other
  2201. \catcode `\&=\other
  2202. % the aux file uses ' as the escape.
  2203. % Turn off \ as an escape so we do not lose on
  2204. % entries which were dumped with control sequences in their names.
  2205. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2206. % Reference to such entries still does not work the way one would wish,
  2207. % but at least they do not bomb out when the aux file is read in.
  2208. \catcode `\{=1 \catcode `\}=2
  2209. \catcode `\%=\other
  2210. \catcode `\'=0
  2211. \catcode `\\=\other
  2212. \openin 1 \jobname.aux
  2213. \ifeof 1 \else \closein 1 \input \jobname.aux
  2214. \fi
  2215. % Open the new aux file.  Tex will close it automatically at exit.
  2216. \openout \auxfile=\jobname.aux
  2217. \endgroup}
  2218.  
  2219.  
  2220. % Footnotes.
  2221.  
  2222. \newcount \footnoteno
  2223.  
  2224. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2225.  
  2226. \let\ptexfootnote=\footnote
  2227.  
  2228. {\catcode `\@=11
  2229. \gdef\footnote{\global\advance \footnoteno by \@ne
  2230. \edef\thisfootno{$^{\the\footnoteno}$}%
  2231. \let\@sf\empty
  2232. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2233. \thisfootno\@sf\parsearg\footnotezzz}
  2234.  
  2235. \gdef\footnotezzz #1{\insert\footins{
  2236. \interlinepenalty\interfootnotelinepenalty
  2237. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2238. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2239. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2240. \footstrut\hang\textindent{\thisfootno}#1\strut}}
  2241.  
  2242. }%end \catcode `\@=11
  2243.  
  2244. % End of control word definitions.
  2245.  
  2246. \message{and turning on texinfo input format.}
  2247.  
  2248. \def\openindices{%
  2249.    \newindex{cp}%
  2250.    \newcodeindex{fn}%
  2251.    \newcodeindex{vr}%
  2252.    \newcodeindex{tp}%
  2253.    \newcodeindex{ky}%
  2254.    \newcodeindex{pg}%
  2255. }
  2256.  
  2257. % Set some numeric style parameters, for 8.5 x 11 format.
  2258.  
  2259. \hsize = 6.5in
  2260. \parindent 15pt
  2261. \parskip 18pt plus 1pt
  2262. \baselineskip 15pt
  2263. \advance\topskip by 1.2cm
  2264.  
  2265. % Prevent underfull vbox error messages.
  2266. \vbadness=10000
  2267.  
  2268. % Use @smallbook to reset parameters for 7x9.5 format
  2269. \def\smallbook{
  2270. \global\lispnarrowing = 0.3in
  2271. \global\baselineskip 12pt
  2272. \global\parskip 3pt plus 1pt
  2273. \global\hsize = 5in
  2274. \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
  2275. \global\vsize=7.5in
  2276. \global\tolerance=700
  2277. \global\hfuzz=1pt
  2278.  
  2279. \global\pagewidth=\hsize
  2280. \global\pageheight=\vsize
  2281. \global\font\ninett=cmtt9
  2282.  
  2283. \global\let\smalllisp=\smalllispx
  2284. \global\let\smallexample=\smalllispx
  2285. \global\def\Esmallexample{\Esmalllisp}
  2286. }
  2287.  
  2288. %% For a final copy, take out the rectangles
  2289. %% that mark overfull boxes (in case you have decided
  2290. %% that the text looks ok even though it passes the margin).
  2291. \def\finalout{\overfullrule=0pt}
  2292.  
  2293. % Turn off all special characters except @
  2294. % (and those which the user can use as if they were ordinary)
  2295. % Define certain chars to be always in tt font.
  2296.  
  2297. \catcode`\"=\active
  2298. \def\activedoublequote{{\tt \char '042}}
  2299. \let"=\activedoublequote
  2300. \catcode`\~=\active
  2301. \def~{{\tt \char '176}}
  2302. \chardef\hat=`\^
  2303. \catcode`\^=\active
  2304. \def^{{\tt \hat}}
  2305. \catcode`\_=\active
  2306. \def_{{\tt \char '137}}
  2307. \catcode`\|=\active
  2308. \def|{{\tt \char '174}}
  2309. \chardef \less=`\<
  2310. \catcode`\<=\active
  2311. \def<{{\tt \less}}
  2312. \chardef \gtr=`\>
  2313. \catcode`\>=\active
  2314. \def>{{\tt \gtr}}
  2315. \catcode`\+=\active
  2316. \def+{{\tt \char 43}}
  2317. %\catcode 27=\active
  2318. %\def^^[{$\diamondsuit$}
  2319.  
  2320. \catcode`\@=0
  2321.  
  2322. % \rawbackslashxx output one backslash character in current font
  2323. {\catcode`\\=\other
  2324. @gdef@rawbackslashxx{\}}
  2325.  
  2326. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  2327. {\catcode`\\=\active
  2328. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  2329.  
  2330. % \normalbackslash outputs one backslash in fixed width font.
  2331. \def\normalbackslash{{\tt\rawbackslashxx}}
  2332.  
  2333. % Say @foo, not \foo, in error messages.
  2334. \escapechar=`\@
  2335.  
  2336. @c \catcode 17=0   @c Define control-q
  2337. \catcode`\\=\active
  2338.  
  2339. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  2340. % That is what \eatinput is for; after that, the `\' should revert to printing 
  2341. % a backslash.
  2342. %
  2343. @gdef@eatinput input texinfo{@fixbackslash}
  2344. @global@let\ = @eatinput
  2345.  
  2346. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  2347. % the first `\{ in the file would cause an error. This macro tries to fix 
  2348. % that, assuming it is called before the first `\' could plausibly occur.
  2349. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  2350.  
  2351. %% These look ok in all fonts, so just make them not special.  The @rm below
  2352. %% makes sure that the current font starts out as the newly loaded cmr10
  2353. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  2354.  
  2355. @textfonts
  2356. @rm
  2357.